package com.seselin.drawing;


import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;

import android.widget.TextView;

public class GetDensityActivity extends Activity {
    private TextView tvShowDensity;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);
        this.tvShowDensity = (TextView) findViewById(R.id.tv_show_density);

        DisplayMetrics metric = new DisplayMetrics();
        GetDensityActivity.this.getWindowManager().getDefaultDisplay().getMetrics(metric);
        int width = metric.widthPixels;
        int height = metric.heightPixels;
        float density = metric.density;
        GetDensityActivity.this.tvShowDensity.setText("屏幕宽度=" + width + "\n屏幕高度=" + height + "\n屏幕密度=" + density + "\n屏幕密度DpI=" + metric.densityDpi);
    }
}